//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.dflc.utils;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class PageRequestEntity {
    @JsonProperty("currentPage")
    private Integer currentPage = 1;
    @JsonProperty("pageSize")
    private Integer pageSize = 10;
    @JsonProperty("sort")
    private List<PageSortEntity> sort;
    @JsonProperty("query")
    private Map<String, Object> query;

    public Page toPage() {
        Page page = new Page();
        page.setCurrent((long)this.getCurrentPage());
        page.setSize((long)this.getPageSize());
        if (CollectionUtils.isNotEmpty(this.getSort())) {
            List<OrderItem> orderList = (List)this.getSort().stream().map((s) -> {
                return new OrderItem(s.getField(), !SortEnum.desc.equals(s.getType()));
            }).collect(Collectors.toList());
            page.setOrders(orderList);
        }

        return page;
    }

    public PageRequestEntity() {
    }

    public Integer getCurrentPage() {
        return this.currentPage;
    }

    public Integer getPageSize() {
        return this.pageSize;
    }

    public List<PageSortEntity> getSort() {
        return this.sort;
    }

    public Map<String, Object> getQuery() {
        return this.query;
    }

    @JsonProperty("currentPage")
    public void setCurrentPage(final Integer currentPage) {
        this.currentPage = currentPage;
    }

    @JsonProperty("pageSize")
    public void setPageSize(final Integer pageSize) {
        this.pageSize = pageSize;
    }

    @JsonProperty("sort")
    public void setSort(final List<PageSortEntity> sort) {
        this.sort = sort;
    }

    @JsonProperty("query")
    public void setQuery(final Map<String, Object> query) {
        this.query = query;
    }

    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof PageRequestEntity)) {
            return false;
        } else {
            PageRequestEntity other = (PageRequestEntity)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label59: {
                    Object this$currentPage = this.getCurrentPage();
                    Object other$currentPage = other.getCurrentPage();
                    if (this$currentPage == null) {
                        if (other$currentPage == null) {
                            break label59;
                        }
                    } else if (this$currentPage.equals(other$currentPage)) {
                        break label59;
                    }

                    return false;
                }

                Object this$pageSize = this.getPageSize();
                Object other$pageSize = other.getPageSize();
                if (this$pageSize == null) {
                    if (other$pageSize != null) {
                        return false;
                    }
                } else if (!this$pageSize.equals(other$pageSize)) {
                    return false;
                }

                Object this$sort = this.getSort();
                Object other$sort = other.getSort();
                if (this$sort == null) {
                    if (other$sort != null) {
                        return false;
                    }
                } else if (!this$sort.equals(other$sort)) {
                    return false;
                }

                Object this$query = this.getQuery();
                Object other$query = other.getQuery();
                if (this$query == null) {
                    if (other$query != null) {
                        return false;
                    }
                } else if (!this$query.equals(other$query)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof PageRequestEntity;
    }

    public int hashCode() {
        boolean PRIME = true;
        int result = 1;
        Object $currentPage = this.getCurrentPage();
        result = result * 59 + ($currentPage == null ? 43 : $currentPage.hashCode());
        Object $pageSize = this.getPageSize();
        result = result * 59 + ($pageSize == null ? 43 : $pageSize.hashCode());
        Object $sort = this.getSort();
        result = result * 59 + ($sort == null ? 43 : $sort.hashCode());
        Object $query = this.getQuery();
        result = result * 59 + ($query == null ? 43 : $query.hashCode());
        return result;
    }

    public String toString() {
        return "PageRequestEntity(currentPage=" + this.getCurrentPage() + ", pageSize=" + this.getPageSize() + ", sort=" + this.getSort() + ", query=" + this.getQuery() + ")";
    }
}
